<?php
require_once('../SuperFunctions.php');
//Contains general functions used througout the Website Admin Section

//------------------------------------------------------------------------------
// Function to check if current user has Treasure Priviliges
//
//   $str = type of user (ie. G, T, E, M, S)
//	returns TRUE if the given user is TREASURE (ie. T or S) and FALSE if not
//          (Case insensitive)
//------------------------------------------------------------------------------
function isUserType_Treasurer($str) {
    if (strcasecmp($str, "T") == 0) {
        return TRUE;
    }

    if (strcasecmp($str, "S") == 0) {
        return TRUE;
    }

    return FALSE;
}

//------------------------------------------------------------------------------
// Function to check if current user has Event Priviliges
//
//   $str = type of user (ie. G, T, E, M, S)
//	returns TRUE if the given user is EVENT (ie. E or S) and FALSE if not
//          (Case insensitive)
//------------------------------------------------------------------------------
function isUserType_Events($str) {
    if (strcasecmp($str, "E") == 0) {
        return TRUE;
    }

    if (strcasecmp($str, "S") == 0) {
        return TRUE;
    }

    return FALSE;
}

//------------------------------------------------------------------------------
// Function to check if current user has Member Priviliges
//
//   $str = type of user (ie. G, T, E, M, S)
//	returns TRUE if the given user is MEMBER (ie. M or S) and FALSE if not
//          (Case insensitive)
//------------------------------------------------------------------------------
function isUserType_Members($str) {
    if (strcasecmp($str, "M") == 0) {
        return TRUE;
    }

    if (strcasecmp($str, "S") == 0) {
        return TRUE;
    }

    return FALSE;
}

//------------------------------------------------------------------------------
// Function to check if current user has Super Priviliges
//
//   $str = type of user (ie. G, T, E, M, S)
//	returns TRUE if the given user is SUPER (ie. S) and FALSE if not
//          (Case insensitive)
//------------------------------------------------------------------------------
//
// True if it is Super, else False
function isUserType_Super($str) {
    if (strcasecmp($str, "S") == 0) {
        return TRUE;
    }

    return FALSE;
}

//------------------------------------------------------------------------------
// Function to change the $sqlDate into a valid input/calendar/form date
//
//   $sqlDate = Sql Date format YYYY-MM-DD
//	returns calendar date format MM/DD/YYYY
//------------------------------------------------------------------------------

function changeSQLDateToFormDate( $sqlDate ) {
    $arrayDate = explode("-", $sqlDate); // Format in => [0]: Year, [1]: Month, [2]: Day
    return $arrayDate[1] . '/' . $arrayDate[2] . '/' . $arrayDate[0]; // Format out => [0]: Month, [1]: Day . [2]: Year
}

//------------------------------------------------------------------------------
// Function to change the $formDate into a valid sql date
//
//   $formDate = Sql Date format MM/DD/YYYY
//	returns calendar date format YYYY-MM-DD
//------------------------------------------------------------------------------

function changeFormDateToSQLDate( $formDate ) {
    $arrayDate = explode("/", $formDate); // [0]: Month, [1]: Day . [2]: Year
    return $arrayDate[2] . '-' . $arrayDate[0] . '-' . $arrayDate[1]; // Format out => [0]: Year, [1]: Month, [2]: Day
}


//------------------------------------------------------------------------------
// Function to return the correspoding name of Membership Status Property
//
//   $statusSymb = character of status { A or I }
//	returns string with appropiate name { Active, Inactive, Unknown}
//------------------------------------------------------------------------------

function giveStatusName ( $statusSymb ) {

    switch (strtolower($statusSymb))
    {
        case 'a':
            return "<font color='#2E00B8'>Active</font>";
            break;

        case 'i':
            return "<font color='#FF6600'>Inactive</font>";
            break;

        default:
            return "<font color='#5C5C5C'>Unknown</font>";
            break;
    }
}

//------------------------------------------------------------------------------
// Function to return the correspoding name of Membership Paid Property
//
//   $statusSymb = integer of paid { 0 or ...,-2,-1,1,2... }
//	returns string with appropiate name { No Paid, Paid}
//------------------------------------------------------------------------------

function givePaidName ( $paidSymb ) {

    switch (strtolower($paidSymb))
    {
        case 0:
            return "<font color='#CC0000'>No Paid</font>";
            break;

        default:
            return "<font color='#00CC00'>Paid</font>";
            break;
    }
}


//------------------------------------------------------------------------------
// Function to return the correspoding name of Event Type Property
//
//   $statusSymb = integer of paid { 0 or ...,-2,-1,1,2... }
//	returns string with appropiate name { No Paid, Paid}
//------------------------------------------------------------------------------

function giveTypeEvent ( $eventType ) {

    switch (strtolower($eventType))
    {
        case 'w':
            return "<font color='#5C5C5C'>Whiffette</font>";
            break;

        case 'a':
            return "<font color='#3D3D3D'>AGM</font>";
            break;

        default:
            return "<font color='#000000'>Regular</font>";
            break;
    }
}

//------------------------------------------------------------------------------
// Function to return the correspoding name of Event Type Property
//
//   $statusSymb = integer of paid { 0 or ...,-2,-1,1,2... }
//	returns string with appropiate name { No Paid, Paid}
//------------------------------------------------------------------------------

function giveStatusEvent ( $eventStatus ) {

    switch (strtolower( $eventStatus ))
    {
        case 'u':
            return "<font color='#00CC00'>Upcoming</font>";
            break;

        case 'c':
            return "<font color='#CC0000'>Cancelled</font>";
            break;

        case 'b':
            return "<font color='#FF6600'>Blocked</font>";
            break;

        default:
            return "<font color='#000000'>Normal</font>";
            break;
    }
}

